

#ifndef _XSTRING_H_
#define _XSTRING_H_

#include "xtypes.h"
#include "xbuffer.h"


/*-------------------------------------------------------------
Classes
-------------------------------------------------------------*/
class CxStringA : protected CxDynamicBuffer
{
public:
	typedef CxStringA _Myt;
	typedef CxDynamicBuffer _Mybase;

public:
	lpcstr_t data() const;
	int_t size() const;

	lpcstr_t c_str() const;
	int_t length() const;

	bool_t empty() const;
	void clear();

	void insert( int_t _Pos, lpcstr_t sz, int_t _Len );
	void insert( int_t _Pos, CxStringA& str, int_t _Len );
	void erase( int_t _Pos, int_t _Len );

	void assign( const CxStringA& str );
	void assign( lpcstr_t sz );
	void append( const CxStringA& str );
	void append( lpcstr_t sz );
	void format( lpcstr_t szFormat, ... );

	CxStringA& operator=( const CxStringA str );
	CxStringA& operator=( lpcstr_t sz );
	CxStringA& operator=( const char_t c );
	CxStringA& operator=( const int_t num );


	CxStringA& operator+=( const CxStringA str );
	CxStringA& operator+=( lpcstr_t sz );
	CxStringA& operator+=( const char_t c );
	CxStringA& operator+=( const int_t num );
	
	CxStringA operator+( const CxStringA& str );
	CxStringA operator+( lpcstr_t sz );
	CxStringA operator+( const char_t c );	
	CxStringA operator+( const int_t num );

	bool_t operator==( const CxStringA& str );
	bool_t operator!=( const CxStringA& str );

	char_t at( int_t _Index ) const;
	char_t& operator[]( int_t _Index );
	const char_t& operator[]( int_t _Index ) const;

	CxStringA substr(int_t _Off, int_t _Count) const;
	int_t find(const _Myt& _Right, int_t _Off=0) const;
	int_t replace( const _Myt& _TargetStr, int_t _Off, const _Myt& _NewStr );
	int_t compare(const _Myt& _Right) const;

public:
	CxStringA();
	virtual ~CxStringA();
	CxStringA(const _Myt& r);
	CxStringA(lpcstr_t sz);
	CxStringA(const char_t c);
	CxStringA(const int_t val, int_t radix=10);

public:
	static CxStringA * Create();
	virtual void Release();


protected:
	void _AutoGrowCapcity(int_t _Size);
	void _MarkTerminator();
	memptr_t _MyPtr() const;

protected:

};

#define CxString CxStringA






#endif //_XSTRING_H_


